import { createRouter, createWebHistory } from 'vue-router'



const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path:'/',
      component: () => import('@/views/主页.vue')
    },
    {
      path:'/collegeIntroduce',
      component: () => import('@/views/学校简介.vue')
    },
    {
      path:'/bookingVisitSchool',
      component: () => import('@/views/预约进校.vue')
    },
    {
      path:'/immediatelyBooking',
      name:'book',
      component: () => import('@/views/立即预约.vue'),
      beforeEnter:(to,from,next) =>{
        sessionStorage.setItem('path',to.fullPath)
        if ( sessionStorage.getItem('token')){
        console.log("去哪个路由"+to);
        console.log("来自那个路由"+from);
          next()
        }else{
          next({name:'Login'})
        }
      }
    },
    {
      path:'/bookingVisitSchoolList',
      component: () => import('@/views/我的预约.vue'),
      beforeEnter:(to,from,next) =>{
        console.log(to);
        sessionStorage.setItem('path',to.fullPath)
  
        if ( sessionStorage.getItem('token')){
          
         
          next()
        }else{
          next({name:'Login'})
        }
      }
    },
    {
      path:'/viewBookingDetail/:id',   /* 访问此路由时，需要在后面传入一个参数 */
      name:'Book',
      component: () => import('@/views/预约进校详情.vue')
    },{
      path:'/PictureStyle',
      component:() => import('@/views/摄影类型.vue')
    },{
      path:'/PictureProduct',
      component:() => import('@/views/产品拍摄.vue')
    },{
      path:'/PictureMan',
      component:() => import ('@/views/人像写真.vue')
    },{
      path:'/PersonalityTrackingServlet',
      component:() => import('@/views/个性跟拍.vue')
    },{
      path:'/ChargeSchedule',
      component:() => import('@/views/收费标准.vue')
    },{
      name:'Login',
      path :'/login',
      component:() => import('@/views/Login.vue')
    },{
      path:'/CreateUser',
      component:() => import('@/views/createUser.vue')
    },{
    path:'/PersonalCenter',
    component:() => import('@/views/个人中心.vue')
    },{
      path:'/PageSearch',
      component:() => import('@/views/页面查找.vue')
    }
  ],
})

export default router
